"use strict";
cc._RF.push(module, 'cf007CDQr5GdICU84vetx1N', 'LevelSystem');
// scripts/Game/System/LevelSystem.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameEngine_1 = require("../../engines/gameEngine");
var gameMode_json_1 = require("../../engines/managers/gameContent/gameMode_json");
var LevelBase_1 = require("../Base/LevelBase");
var SystemBase_1 = require("../Base/SystemBase");
var Const_1 = require("../Const");
var MainRoot_1 = require("../MainRoot");
var LevelSystem = /** @class */ (function (_super) {
    __extends(LevelSystem, _super);
    function LevelSystem() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.systemName = "===主模式关卡系统";
        _this.level_Save_Content = "level_Save_Content"; // 所有模式的关卡信息存储键值
        _this.m_levelContent = null;
        /** 默认模式 */
        _this.m_normalLevelMap = {};
        /** 最新关卡模式 */
        _this.m_newwestLevelMap = {};
        /** 神奇汉子 */
        _this.m_shenqiLevelMap = {};
        /** 玩梗消除 */
        _this.m_wangengLevelMap = {};
        /** 连线达人 */
        _this.m_lianxianLevelMap = {};
        _this.needUnlock = false; // 是否需要播放关卡解锁动画
        _this.stroage = null;
        _this.currentContent = null;
        return _this;
    }
    Object.defineProperty(LevelSystem.prototype, "GameBundle", {
        get: function () {
            return cc.assetManager.getBundle("gameBundle");
        },
        enumerable: false,
        configurable: true
    });
    //TODO 新模式请看这里
    /**
     * 获取关卡信息
     * @param mode 关卡属于的模式
     * @param levelNum 关卡数，默认为模式当前关卡
     * @returns
     */
    LevelSystem.prototype.GetSignleLevelInfo = function (mode, levelNum) {
        if (!levelNum) {
            levelNum = this.GetCurrLevel(mode);
        }
        // else if (mode == 3) {
        //     levelNum = this.GetShenqiLevel(mode);
        // }
        // else if (mode == 4) {
        //     levelNum = this.GetWangengLevel(mode);
        // }
        // else if (mode == 5) {
        //     levelNum = this.GetLianxianLevel(mode);
        // }
        switch (mode) {
            case gameMode_json_1.GAME_MODE.NORMAL:
                return this.m_normalLevelMap[this.realNum(levelNum, mode)];
            case gameMode_json_1.GAME_MODE.CARD_COMPOSITION:
                return this.m_newwestLevelMap[this.realNum(levelNum, mode)];
            case gameMode_json_1.GAME_MODE.SHENQIHANZI:
                return this.m_shenqiLevelMap[this.realNum(levelNum, mode)];
            case gameMode_json_1.GAME_MODE.WANGENG:
                return this.m_wangengLevelMap[this.realNum(levelNum, mode)];
            case gameMode_json_1.GAME_MODE.LIANXIAN:
                return this.m_lianxianLevelMap[this.realNum(levelNum, mode)];
        }
        //TODO 新模式请看这里
    };
    LevelSystem.prototype.GetModeLevelInfo = function (mode) {
        switch (mode) {
            case gameMode_json_1.GAME_MODE.NORMAL:
                return this.m_normalLevelMap;
            case gameMode_json_1.GAME_MODE.CARD_COMPOSITION:
                return this.m_newwestLevelMap;
            case gameMode_json_1.GAME_MODE.SHENQIHANZI:
                return this.m_shenqiLevelMap;
            case gameMode_json_1.GAME_MODE.WANGENG:
                return this.m_wangengLevelMap;
            case gameMode_json_1.GAME_MODE.LIANXIAN:
                return this.m_lianxianLevelMap;
        }
        //TODO 新模式请看这里
    };
    LevelSystem.prototype.realNum = function (levelNum, mode) {
        var realLevelNum = levelNum % this.m_levelContent[mode].maxLevel;
        if (!realLevelNum) {
            realLevelNum = this.m_levelContent[mode].maxLevel;
        }
        if (realLevelNum > this.m_levelContent[mode].maxLevel) {
            realLevelNum = 1;
        }
        // console.warn(this.m_levelContent[mode].maxLevel, realLevelNum);
        return realLevelNum;
    };
    LevelSystem.prototype.GetFarLevel = function (mode) {
        return this.m_levelContent[mode].farLevel || 1;
    };
    LevelSystem.prototype.GetNewwestLevel = function (mode) {
        return this.m_levelContent[mode].newwestLevel || 1;
    };
    LevelSystem.prototype.GetShenqiLevel = function (mode) {
        return this.m_levelContent[mode].shenqiLevel || 1;
    };
    LevelSystem.prototype.GetWangengLevel = function (mode) {
        return this.m_levelContent[mode].wangengLevel || 1;
    };
    LevelSystem.prototype.GetLianxianLevel = function (mode) {
        return this.m_levelContent[mode].lianxianLevel || 1;
    };
    LevelSystem.prototype.GetCurrLevel = function (mode) {
        return this.m_levelContent[mode].currLevel || 1;
    };
    LevelSystem.prototype.GetMaxLevel = function (mode) {
        return this.m_levelContent[mode].maxLevel || 1;
    };
    LevelSystem.prototype.GetUnlockLevel = function (mode) {
        return this.m_levelContent[mode].unlockLevleList || [1];
    };
    LevelSystem.prototype.SystemInit = function () {
        var pram = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            pram[_i] = arguments[_i];
        }
        _super.prototype.SystemInit.call(this);
        this.stroage = gameEngine_1.default.getServices().localStorageSrv;
        this.m_levelContent = {
            0: { currLevel: 1, farLevel: 1, unlockLevleList: [1] },
            1: { currLevel: 1, farLevel: 1, unlockLevleList: [1] },
            3: { currLevel: 1, farLevel: 1, unlockLevleList: [1] },
            4: { currLevel: 1, farLevel: 1, unlockLevleList: [1] },
            5: { currLevel: 1, farLevel: 1, unlockLevleList: [1] },
            6: { currLevel: 1, farLevel: 1, unlockLevleList: [1] },
            7: { currLevel: 1, farLevel: 1, unlockLevleList: [1] },
            8: { currLevel: 1, farLevel: 1, unlockLevleList: [1] },
        };
        //TODO 新模式请看这里
        var init = function (config, map) {
            for (var index = 0; index < config.length; index++) {
                var element = config[index];
                map[element.id] = element.content;
            }
        };
        var initNewwest = function (config, map) {
            for (var index = 0; index < config.length; index++) {
                var element = config[index];
                map[element.id] = element.content;
            }
        };
        var initShenQi = function (config, map) {
            for (var index = 0; index < config.length; index++) {
                var element = config[index];
                map[element.id] = element.content;
            }
        };
        var initWanGeng = function (config, map) {
            for (var index = 0; index < config.length; index++) {
                var element = config[index];
                map[element.id] = element.content;
            }
        };
        var initLianXian = function (config, map) {
            for (var index = 0; index < config.length; index++) {
                var element = config[index];
                map[element.id] = element.content;
            }
        };
        // NOTE 添加模式需要修改的地方
        init(MainRoot_1.default.ConfigSerive.NormalLevelList, this.m_normalLevelMap);
        initNewwest(MainRoot_1.default.ConfigSerive.NewestLevelList, this.m_newwestLevelMap);
        initShenQi(MainRoot_1.default.ConfigSerive.ShenqiLevelList, this.m_shenqiLevelMap);
        initWanGeng(MainRoot_1.default.ConfigSerive.WanGengLevelList, this.m_wangengLevelMap);
        initLianXian(MainRoot_1.default.ConfigSerive.LianXianLevelList, this.m_lianxianLevelMap);
        //TODO 新模式请看这里
        var allContent = this.stroage.getStorage(this.level_Save_Content);
        if (allContent) {
            var object = JSON.parse(allContent);
            for (var key in object) {
                if (Object.prototype.hasOwnProperty.call(object, key)) {
                    var element = object[key];
                    this.m_levelContent[key] = element;
                }
            }
            // this.m_levelContent = JSON.parse(allContent);
        }
        /** 配置默认表 */
        var array = MainRoot_1.default.ConfigSerive.LevelSourceList;
        for (var index = 0; index < array.length; index++) {
            var element = array[index];
            var levelSource = MainRoot_1.default.ConfigSerive[element.responName];
            // this.m_levelContent[element.name] = <IGameModeContent>{};
            this.m_levelContent[element.mode].maxLevel = levelSource.length; // 获取配置服务中的特定配置表的长度
            this.m_levelContent[element.mode].farLevel = Math.min(levelSource.length, this.m_levelContent[element.mode].farLevel);
            this.m_levelContent[element.mode].currLevel = Math.min(levelSource.length, this.m_levelContent[element.mode].currLevel);
            this.m_levelContent[element.mode].unlockLevleList =
                this.m_levelContent[element.mode].unlockLevleList;
            if (this.m_levelContent[element.mode].unlockLevleList == null ||
                this.m_levelContent[element.mode].unlockLevleList == undefined) {
                //兼容线上
                this.m_levelContent[element.mode].unlockLevleList = [];
                for (var i = 1; i <= this.m_levelContent[element.mode].farLevel; i++) {
                    this.m_levelContent[element.mode].unlockLevleList.push(i);
                }
                this.OnLevelChange();
            }
        }
        /** 配置最新关卡表 */
        var arrayNewest = MainRoot_1.default.ConfigSerive.NewestMSLevelSourceList;
        for (var index = 0; index < arrayNewest.length; index++) {
            var element = arrayNewest[index];
            var levelSource = MainRoot_1.default.ConfigSerive[element.responName];
            // this.m_levelContent[element.name] = <IGameModeContent>{};
            this.m_levelContent[element.mode].maxLevel = levelSource.length; // 获取配置服务中的特定配置表的长度
            this.m_levelContent[element.mode].farLevel = Math.min(levelSource.length, this.m_levelContent[element.mode].farLevel);
            this.m_levelContent[element.mode].currLevel = Math.min(levelSource.length, this.m_levelContent[element.mode].currLevel);
            this.m_levelContent[element.mode].unlockLevleList =
                this.m_levelContent[element.mode].unlockLevleList;
            if (this.m_levelContent[element.mode].unlockLevleList == null ||
                this.m_levelContent[element.mode].unlockLevleList == undefined) {
                //兼容线上
                this.m_levelContent[element.mode].unlockLevleList = [];
                for (var i = 1; i <= this.m_levelContent[element.mode].farLevel; i++) {
                    this.m_levelContent[element.mode].unlockLevleList.push(i);
                }
                this.OnLevelChange();
            }
        }
        /** 配置神奇汉字表 */
        var arrayShenQi = MainRoot_1.default.ConfigSerive.ShenqiMSLevelSourceList;
        for (var index = 0; index < arrayShenQi.length; index++) {
            var element = arrayShenQi[index];
            var levelSource = MainRoot_1.default.ConfigSerive[element.responName];
            // this.m_levelContent[element.name] = <IGameModeContent>{};
            this.m_levelContent[element.mode].maxLevel = levelSource.length; // 获取配置服务中的特定配置表的长度
            this.m_levelContent[element.mode].farLevel = Math.min(levelSource.length, this.m_levelContent[element.mode].farLevel);
            this.m_levelContent[element.mode].currLevel = Math.min(levelSource.length, this.m_levelContent[element.mode].currLevel);
            this.m_levelContent[element.mode].unlockLevleList =
                this.m_levelContent[element.mode].unlockLevleList;
            if (this.m_levelContent[element.mode].unlockLevleList == null ||
                this.m_levelContent[element.mode].unlockLevleList == undefined) {
                //兼容线上
                this.m_levelContent[element.mode].unlockLevleList = [];
                for (var i = 1; i <= this.m_levelContent[element.mode].farLevel; i++) {
                    this.m_levelContent[element.mode].unlockLevleList.push(i);
                }
                this.OnLevelChange();
            }
        }
        /** 配置玩梗消除表 */
        var arrayWanGeng = MainRoot_1.default.ConfigSerive.WangengMSLevelSourceList;
        for (var index = 0; index < arrayWanGeng.length; index++) {
            var element = arrayWanGeng[index];
            var levelSource = MainRoot_1.default.ConfigSerive[element.responName];
            // this.m_levelContent[element.name] = <IGameModeContent>{};
            this.m_levelContent[element.mode].maxLevel = levelSource.length; // 获取配置服务中的特定配置表的长度
            this.m_levelContent[element.mode].farLevel = Math.min(levelSource.length, this.m_levelContent[element.mode].farLevel);
            this.m_levelContent[element.mode].currLevel = Math.min(levelSource.length, this.m_levelContent[element.mode].currLevel);
            this.m_levelContent[element.mode].unlockLevleList =
                this.m_levelContent[element.mode].unlockLevleList;
            if (this.m_levelContent[element.mode].unlockLevleList == null ||
                this.m_levelContent[element.mode].unlockLevleList == undefined) {
                //兼容线上
                this.m_levelContent[element.mode].unlockLevleList = [];
                for (var i = 1; i <= this.m_levelContent[element.mode].farLevel; i++) {
                    this.m_levelContent[element.mode].unlockLevleList.push(i);
                }
                this.OnLevelChange();
            }
        }
        var arrayLianXian = MainRoot_1.default.ConfigSerive.LianxianMSLevelSourceList;
        for (var index = 0; index < arrayLianXian.length; index++) {
            var element = arrayLianXian[index];
            var levelSource = MainRoot_1.default.ConfigSerive[element.responName];
            // this.m_levelContent[element.name] = <IGameModeContent>{};
            this.m_levelContent[element.mode].maxLevel = levelSource.length; // 获取配置服务中的特定配置表的长度
            this.m_levelContent[element.mode].farLevel = Math.min(levelSource.length, this.m_levelContent[element.mode].farLevel);
            this.m_levelContent[element.mode].currLevel = Math.min(levelSource.length, this.m_levelContent[element.mode].currLevel);
            this.m_levelContent[element.mode].unlockLevleList =
                this.m_levelContent[element.mode].unlockLevleList;
            if (this.m_levelContent[element.mode].unlockLevleList == null ||
                this.m_levelContent[element.mode].unlockLevleList == undefined) {
                //兼容线上
                this.m_levelContent[element.mode].unlockLevleList = [];
                for (var i = 1; i <= this.m_levelContent[element.mode].farLevel; i++) {
                    this.m_levelContent[element.mode].unlockLevleList.push(i);
                }
                this.OnLevelChange();
            }
        }
        // this.Log(this.m_levelContent);
    };
    /**
     * 变换大关卡,大关卡变换时仅可调用此接口
     * @param levelNum 大关卡数
     * @param mode 游戏模式
     */
    LevelSystem.prototype.ChangeLevel = function (levelNum, mode) {
        this.m_levelContent[mode].currLevel = levelNum;
        this.m_levelContent[mode].farLevel = Math.max(levelNum, this.m_levelContent[mode].farLevel);
        this.m_levelContent[mode].farLevel = Math.min(this.m_levelContent[mode].maxLevel, this.m_levelContent[mode].farLevel);
        if (this.m_levelContent[mode].unlockLevleList.indexOf(levelNum) < 0) {
            this.m_levelContent[mode].unlockLevleList.push(levelNum);
        }
        this.m_levelContent[mode].unlockLevleList.sort(function (a, b) {
            return a - b;
        });
        this.OnLevelChange();
    };
    LevelSystem.prototype.getIsUnLockAll = function () {
        var have = false;
        for (var m = 0; m < gameMode_json_1.GAME_MODE.LIANXIAN; m++) {
            if (this.m_levelContent[m]) {
                for (var i = 0; i < this.m_levelContent[m].maxLevel + 1; i++) {
                    if (this.m_levelContent[m].unlockLevleList.indexOf(i) < 0) {
                        have = true;
                    }
                }
            }
        }
        return have;
    };
    LevelSystem.prototype.unAllLock = function (mode) {
        // for(let m=0;m<GAME_MODE.LIANXIAN;m++)
        // {
        //     if(this.m_levelContent[m])
        //     {
        //         for(let i=0;i<this.m_levelContent[m].maxLevel+1;i++)
        //         {
        //             if (this.m_levelContent[m].unlockLevleList.indexOf(i) < 0) {
        //                 this.m_levelContent[m].unlockLevleList.push(i);
        //             }
        //         }
        //         this.m_levelContent[m].unlockLevleList.sort((a: number, b: number) => {
        //             return a - b;
        //         });
        //     }
        // }
        // this.OnLevelChange();
        gameEngine_1.default.getServices().userSrv.setLevelAllUnlockTime();
        gameEngine_1.default.getServices().userSrv.setLevelAllUnlockFlag(true);
    };
    LevelSystem.prototype.OnLevelChange = function () {
        this.stroage.setStorage(this.level_Save_Content, JSON.stringify(this.m_levelContent));
        return true;
    };
    Object.defineProperty(LevelSystem.prototype, "CurrentContent", {
        get: function () {
            return this.currentContent;
        },
        enumerable: false,
        configurable: true
    });
    /**
     * 增加关卡计数
     */
    LevelSystem.prototype.AddLevel = function (mode, num) {
        if (num === void 0) { num = 1; }
        console.warn("关卡加1", mode);
        this.ChangeLevel(this.m_levelContent[mode].currLevel + num, mode);
    };
    /**
     * 加载关卡
     * @param bundleName 关卡所在的分包名
     * @param levelNum 关卡数
     */
    LevelSystem.prototype.LoadLevel = function (bundleName, mode, levelNum, isShowLoading, infinityInfo) {
        if (isShowLoading === void 0) { isShowLoading = true; }
        if (infinityInfo === void 0) { infinityInfo = null; }
        return __awaiter(this, void 0, void 0, function () {
            var realNum, content, sceneMode, prams, object, level, levelType, name, sceneCom;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (!levelNum) {
                            levelNum = this.GetCurrLevel(mode);
                        }
                        realNum = this.realNum(levelNum, mode);
                        this.ChangeLevel(realNum, mode);
                        content = this.GetSignleLevelInfo(mode, realNum);
                        this.currentContent = content;
                        sceneMode = mode;
                        //mode 加载的包名 如果填写 会直接强制去load mode Id 所指向的bundleName 方便各游戏穿插调佣
                        if (content.mode !== undefined && content.mode !== null) {
                            sceneMode = content.mode;
                            // console.log("?????", sceneMode);
                        }
                        if (infinityInfo) {
                            content = infinityInfo;
                        }
                        prams = {
                            bundleName: content.bundleName,
                            mode: mode,
                            name: content.name,
                            tips: content.tips,
                            title: content.title,
                            winText: content.winText,
                            loseText: content.loseText,
                            reward: content.reward,
                            level: content.level,
                            sourceLevel: content.sourceLevel,
                            gameAloneBundle: content.gameAloneBundle,
                            oldLevel: content.oldLevel,
                            hideTitle: content.hideTitle,
                            subPower: content.subPower,
                            infinityFlag: content.infinityFlag,
                            levelNum: content.levelNum,
                            levelType: content.levelType
                        };
                        object = MainRoot_1.default.LevelSystem.GetModeLevelInfo(mode);
                        level = this.GetCurrLevel(mode);
                        if (!prams.gameAloneBundle) return [3 /*break*/, 3];
                        return [4 /*yield*/, new Promise(function (resolve) {
                                cc.assetManager.loadBundle(prams.gameAloneBundle, function (error, bundle) {
                                    if (error) {
                                        console.error(error);
                                        resolve();
                                        return;
                                    }
                                    resolve();
                                });
                            })];
                    case 1:
                        _a.sent();
                        return [4 /*yield*/, gameEngine_1.default.getManagers().soundMgr.loadSoundBundle("level" + object[level]['level'], prams.gameAloneBundle)];
                    case 2:
                        _a.sent();
                        _a.label = 3;
                    case 3:
                        levelType = content.levelType;
                        console.log(levelType, "关卡类型>>>>>>>>>>>");
                        return [4 /*yield*/, this.loadOneTypeBundle(levelType)];
                    case 4:
                        _a.sent();
                        return [4 /*yield*/, gameEngine_1.default.getManagers().gameMgr.selectMode(sceneMode, isShowLoading)];
                    case 5:
                        _a.sent();
                        name = content.name;
                        // this.Log("real", realNum, name);
                        gameEngine_1.services()
                            .miniGameSrv.getAppApiInstance()
                            .reportAnalytics("Level", {
                            loadLevel: Const_1.MODE_NAME_MAP[mode] + ":" + realNum,
                        });
                        sceneCom = gameEngine_1.default.Canvas().getComponent(LevelBase_1.default);
                        return [4 /*yield*/, new Promise(function (resolve, reject) {
                                if (!name) {
                                    resolve();
                                    console.warn("非常规类型", sceneCom == null);
                                    // return;
                                }
                                else {
                                    var loadPrefabOver = function (err, prefab) {
                                        if (err) {
                                            console.error(err);
                                            reject();
                                            return;
                                        }
                                        var gamePlayerLayer = gameEngine_1.default.Canvas().getChildByName("GamePlayLayer");
                                        if (gamePlayerLayer) {
                                            var node = cc.instantiate(prefab);
                                            node.name = "LevelNode";
                                            var com = node.getComponent(LevelBase_1.default);
                                            // console.warn("?????", com == undefined);
                                            com && com.Init(prams);
                                            gamePlayerLayer.addChild(node);
                                            // node.y-=100;
                                            resolve();
                                        }
                                        else {
                                            console.error("没找到游戏对象");
                                        }
                                    };
                                    if (prams.gameAloneBundle) {
                                        MainRoot_1.default.GetBundle(prams.gameAloneBundle).load(name, loadPrefabOver);
                                    }
                                    else {
                                        MainRoot_1.default.GetBundle(bundleName).load("Level/" + name, loadPrefabOver);
                                    }
                                }
                            })];
                    case 6:
                        _a.sent();
                        gameEngine_1.managers().soundMgr.playSound('mainSound/inLevel');
                        sceneCom && sceneCom.Init(prams);
                        MainRoot_1.default.UIModel.hideLoading();
                        return [2 /*return*/, Promise.resolve()];
                }
            });
        });
    };
    /**
     * 加载一种类型的游戏的bundle
     */
    LevelSystem.prototype.loadOneTypeBundle = function (type) {
        var _this = this;
        gameEngine_1.default.getModules().uiControlModule.showLoading(null, "正在加载关卡资源");
        return new Promise(function (resolve) {
            cc.assetManager.loadBundle(_this.getBundleNameByType(type), cc.AssetManager.Bundle, function (err, bundle) {
                resolve();
            });
        });
    };
    LevelSystem.prototype.getOneBundByInstant = function (bundleName) {
        return cc.assetManager.getBundle(bundleName);
    };
    LevelSystem.prototype.getBundleNameByType = function (type) {
        var bundleName = "";
        switch (type) {
            case 0: {
                bundleName = "peopleArchery";
                break;
            }
            case 1: {
                bundleName = "decompressionLibrary";
                break;
            }
            case 3: {
                bundleName = "LianXian";
                break;
            }
            case 4: {
                bundleName = "bunchbunchbunch";
                break;
            }
            case 5: {
                bundleName = "goldMiner";
                break;
            }
        }
        return bundleName;
    };
    LevelSystem.prototype.getOneTypeBundle = function (type) {
        return cc.assetManager.getBundle(this.getBundleNameByType(type));
    };
    return LevelSystem;
}(SystemBase_1.default));
exports.default = LevelSystem;

cc._RF.pop();